package cn.online.service;

import java.util.List;

import cn.online.dao.ProblemDao;
import cn.online.dao.ReplyDao;
import cn.online.model.Problem;
import cn.online.model.Reply;

public class ReplyService {
	
	private ProblemDao problemDao;
	private ReplyDao replyDao;
	
	public void setProblemDao(ProblemDao problemDao) {
		this.problemDao = problemDao;
	}
	public void setReplyDao(ReplyDao replyDao) {
		this.replyDao = replyDao;
	}
	
	public void insert(Reply reply,Integer problemId){
		Problem problem = problemDao.findById(problemId);
		reply.setRproblem(problemId);
		replyDao.save(reply);
	}
	
	public void delete(Integer id){
		
	}
	
	public void updateReply(Reply reply){
		if(reply!=null){
		reply.setRdate(new java.util.Date());
		replyDao.update(reply);
		}
	}
	
	public List<Reply> getListByProblemId(Integer id){
		return replyDao.getReplyByProblemId(id);
	}
	
	public Reply get(Integer id){
		return replyDao.findById(id);
	}
}
